﻿using System;
using System.Threading;

namespace LambdaGp.Core
{
    public static class ThreadSafeRandom
    {
        private static Random _coreRandom = new Random();

        [ThreadStatic]
        private static Random _random;

        public static Random Random
        {
            get
            {
                if (_random == null)
                {
                    lock (_coreRandom)
                    {
                        _random = new Random(_coreRandom.Next());
                    }
                }
                return _random;
            }
        }
    }
}